package com.yonyou.hxjy.utils;

import com.yonyou.hxjy.dao.JobLogDao;
import com.yonyou.hxjy.model.JobLogModel;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;
@Component
@Slf4j
public class InsertLoggerUtil {
    @Resource
    public JobLogDao jobLogDao;
    private static final Logger logger = LoggerFactory.getLogger(InsertLoggerUtil.class);
    public  void InsertLogger(String code, String oneL, String mags,String jobClass) {  // 单据编号、是否成功、详细信息
        try {
            JobLogModel jobLogDTO = new JobLogModel();
            jobLogDTO.setJobClass(jobClass);
            jobLogDTO.setJobCode(code);
            jobLogDTO.setJobTime(new Date());
            jobLogDTO.setJobResult(oneL);
            jobLogDTO.setJobLogUser("dfroot");
            jobLogDTO.setJobResultMessage(mags);
            jobLogDao.insertJobLog(jobLogDTO);
        } catch (Exception e) {
            logger.error(jobClass+"插入日志错误：" + e.getMessage());
        }
    }
}
